package com.retail.alipay.config;


import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;


/**
 * @Author：开心就好
 * @Description:
 * @Date:2024/4/13
 */
@Configuration
@Log4j2
public class DelayQueueConfig {

    @Bean
    public Queue queue(){
        return new Queue("QueueOne");
    }

    @Bean
    public Queue DelayQueue(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("x-message-ttl",10000L);
        map.put("x-dead-letter-exchange","DELAY_EXCHANGE");
        map.put("x-dead-letter-routing-key","QueueOne");
        return new Queue("DelayQueue",true,false,false,map);
    }

    @Bean
    public Exchange exchange(){
        return new DirectExchange("DELAY_EXCHANGE");
    }

    @Bean
    public Binding binding(){
        return new Binding(
                "QueueOne",
                Binding.DestinationType.QUEUE,
                "DELAY_EXCHANGE","QueueOne",null);
    }

    @Bean
    public Binding delayBinding(){
        return new Binding("DelayQueue", Binding.DestinationType.QUEUE,
                "DELAY_EXCHANGE","DelayQueue",null);
    }


}
